$(function () {
    $('.btn_rgister').submit(function () {
        var username = $("#username").val();
        var password = $("#password").val();
        var re_password = $("#re_password").val();
        var address = $("#address").val();
        var phone = $("#phone").val();
        var code = $("#code").val();
        if (!username) {
            alert("请输入用户名");
            return;
        }
        if (!password) {
            alert("请输入密码");
            return;
        } else if (password.length < 6) {
            alert("密码长度不够6位");
            return;
        }
        if (password != re_password) {
            alert("两次密码不同");
            return;
        }
        if (!address) {
            alert("请输入地址");
            return;
        }
        if (!phone) {
            alert("请输入手机号");
            return;
        }
        if (!code) {
            alert("请输入验证码");
            return;
        }
        var params = {
            'username': username,
            'password': password,
            'address': address,
            'phone': phone,
            // "code": code,
        };
        $.ajax({
            url: "/passport/signup",
            type: "post",
            data: JSON.stringify(params),
            contentType: "application/json",
            success: function (resp) {
                if (resp.errno == 0) {
                    location.href = '/'
                } else {
                    alert(resp.errmsg)
                }
            }
        })
    })
});




